package com.zhk.entry.test;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Observer;

/**
 * @Description 保姆类
 * @Author zhanghk
 * @Date 2021/4/6 17:23
 */
public class Nanny implements InvocationHandler {

    private Observer person;

    public Nanny() {
        person = new Person();
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("保姆开始照顾孩子");
        Object invoke = method.invoke(person, args);

        return invoke;
    }
}
